package cc.idoone.spring_boot_hello.mybatis.h2.service;

import cc.idoone.spring_boot_hello.mybatis.h2.dao.BaseMapper;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author hemj
 * @since 2017-10-20
 */
@Transactional(transactionManager = "h2MyBatisTransactionManager")
public abstract class AbstractBaseService<T, I> implements BaseService<T, I> {

	protected abstract BaseMapper<T, I> getMapper();

	@Override
	public int deleteByPrimaryKey(I id) {
		return getMapper().deleteByPrimaryKey(id);
	}

	@Override
	public int insert(T record) {
		return getMapper().insert(record);
	}

	@Override
	public int insertSelective(T record) {
		return getMapper().insertSelective(record);
	}

	@Override
	public T selectByPrimaryKey(I id) {
		return getMapper().selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(T record) {
		return getMapper().updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(T record) {
		return getMapper().updateByPrimaryKey(record);
	}
}
